var menuList;

$("document").ready(function () {
    window.menuList = new Vue({
        el: "#menuList",
        data: {
            
            menuList: [
                {
                    name: "呼叫客服",
                    menuRight: {},
                    chirdenMenuId: null,
                    type: '',

                    value: {

                    },
                    chirden: [{
                            "type": "view",
                            "name": "搜索",
                            "url": "http://www.soso.com/"
                        },
                        {
                            "type": "view",
                            "name": "百度",
                            "url": "http://www.baidu.com/"
                        },
                        {
                            "type": "click",
                            "name": "赞一下我们",
                            "key": "V1001_GOOD"
                        }
                    ]

                },
                {
                    name: "呼叫客服",
                    menuRight: {},
                    chirdenMenuId: null,
                    type: '',

                    value: {

                    },
                    chirden: [{
                            "type": "view",
                            "name": "搜索",
                            "url": "http://www.soso.com/"
                        },
                        {
                            "type": "view",
                            "name": "百度",
                            "url": "http://www.baidu.com/"
                        },
                        {
                            "type": "click",
                            "name": "赞一下我们",
                            "key": "V1001_GOOD"
                        }
                    ]

                },
                {
                    name: "呼叫客服",
                    menuRight: {},
                    chirdenMenuId: null,
                    type: '',

                    value: {

                    },
                    chirden: [{
                            "type": "view",
                            "name": "搜索",
                            "url": "http://www.soso.com/"
                        },
                        {
                            "type": "view",
                            "name": "百度",
                            "url": "http://www.baidu.com/"
                        },
                        {
                            "type": "click",
                            "name": "赞一下我们",
                            "key": "V1001_GOOD"
                        }
                    ]

                }
            ],
            typeList: [{
                    type: 'view',
                    name: '网页类型',
                },
                {
                    type: 'click',
                    name: '点击类型'
                },
                {
                    type: 'miniprogram',
                    name: '小程序类型'
                },
                {
                    type: 'scancode_waitmsg',
                    name: '扫码'
                },
                {
                    type: 'pic_sysphoto',
                    name: '系统拍照发图'
                },
                {
                    type: 'pic_photo_or_album',
                    name: '拍照或者相册发图'
                },
                {
                    type: 'pic_weixin',
                    name: '微信相册发图'
                },
                {
                    type: 'location_select',
                    name: '发送位置'
                },
                {
                    type: 'media_id',
                    name: '公众号素材图片'
                },
                {
                    type: 'view_limited',
                    name: '公众号素材图文'
                }
            ],
            

        },
        created: function () {
            
            this.menuList.forEach(function(item,index){
                console.log(item.type)
                item.menuRight.type = item.type
                
                item.menuRight.id = index
                item.menuRight.chirdenId = null
            })
            
        },
        methods: {
            clickAddMenu: function (index) {
                this.menuList[index].chirden.push({
                    "type": "view",
                    "name": "搜索",
                    "url": "http://www.soso.com/"
                })
            },
            deleteThisMenu: function (index, chirdIndex) {
                this.menuList[index].chirden.splice(chirdIndex, 1)
            },
            focusValue: function (index, chirdIndex) {
                console.log(index,chirdIndex)
                this.menuList[index].chirdenMenuId = chirdIndex
                if (chirdIndex == null) {
                    this.menuList[index].menuRight = {
                        type: this.menuList[index].type,
                        id: index,
                        chirdenId: chirdIndex
                    }
                    return;
                }
                console.log(this.menuList[index].chirden[chirdIndex].type)
                console.log(this.menuList[index].chirden[chirdIndex].name)
                this.menuList[index].menuRight = {
                    type: this.menuList[index].chirden[chirdIndex].type,
                    id: index,
                    chirdenId: chirdIndex
                }
            },
            chooseType: function (funcType, index) {
                console.log(funcType.type)
                if (this.menuList[index].chirdenMenuId == null) {
                    this.menuList[index].type == funcType.type
                    console.log(this.menuList[index].type)
                    return;
                }
                this.menuList[index].chirden[this.menuList[index].chirdenMenuId].type = funcType.type
                console.log(this.menuList[index].chirden[this.menuList[index].chirdenMenuId].type)
            }
        }
    })
})